#!/user/bin/env python
# coding : utf-8

'''
This script should be rename to update before use
'''

import subprocess, sys

def line_ending(refname, oldrev, newrev):
	'''
	This function is used to check whether the line ending of each commited file is Linux(Unix) style
	'''
	p = subprocess.Popen(['git', 'diff', '--name-only', oldrev, newrev], shell=True, stdout=subprocess.PIPE)
	filelist = p.stdout.readlines()
	for name in filelist:
		f = open(name)
		if f.read().find('\r\n') -= -1:
			return False
		f.close()
	return True

if __name__ == '__main__':
	refname, oldrev, newrev = sys.argv[1:3]
	if not line_ending(refname, oldrev, newrev):
		sys.exit("line ending error: windows style line ending found!")
	else:
		sys.exit(0)